home *** CD-ROM | disk | FTP | other *** search
/ NeXT Enterprise Objects Framework 1.1 / NeXT Enterprise Objects Framework 1.1.iso / NextDeveloper / Headers / eoadaptors / Oracle7 / OracleColumn.h < prev    next >
Encoding:
Text File  |  1994-12-06  |  7.3 KB  |  217 lines

  1. // OracleColumn.h
  2. // Copyright (c) 1994, NeXT Computer, Inc.  All rights reserved.
  3.  
  4. #import "ociapr.h"
  5. #import <eoaccess/eoaccess.h>
  6.  
  7. // This class is used internally by the Oracle adaptor to maintain the state
  8. // of the various column buffers which are needed to fetch data.
  9.  
  10. // These are the codes for internal (in the server) Oracle data types.
  11. // OracleServerTypes are mapped by the adaptor to the "external type" string
  12. // of an EOAttribute (unfortunately, Oracle and EOF have opposite ideas of
  13. // what internal and external mean).
  14.  
  15. typedef enum { 
  16.     OraVARCHAR2 =  1,
  17.     OraNUMBER   =  2,
  18.     OraLONG     =  8,
  19.     OraROWID    = 11,
  20.     OraDATE     = 12,
  21.     OraRAW      = 23,
  22.     OraLONGRAW  = 24,
  23.     OraCHAR     = 96,
  24.     OraMLSLABEL = 106
  25. } OracleServerType;
  26.  
  27. // These are the codes for the external (in the client) Oracle data types.
  28. // OracleClientTypes specify how OCI should convert the data from the rdbms
  29. // into a form that can be consumed by the adaptor, or to describe the format
  30. // of of data passed into OCI by the adaptor.  Not all of these are used by
  31. // the current implementation, but are included here for completeness.
  32.  
  33. typedef enum {
  34.     OciVARCHAR2    =  1,
  35.     OciNUMBER      =  2,
  36.     OciINTEGER     =  3,
  37.     OciFLOAT       =  4,
  38.     OciSTRING      =  5,
  39.     OciVARNUM      =  6,
  40.     OciPACKED      =  7,
  41.     OciLONG        =  8,
  42.     OciVARCHAR     =  9,
  43.     OciROWID       = 11,
  44.     OciDATE        = 12,
  45.     OciVARRAW      = 15,
  46.     OciRAW         = 23,
  47.     OciLONGRAW     = 24,
  48.     OciUNSIGNED    = 68,
  49.     OciDISPLAY     = 91,
  50.     OciLONGVARCHAR = 94,
  51.     OciLONGVARRAW  = 95,
  52.     OciCHAR        = 96,
  53.     OciCHARZ       = 97,
  54.     OciMLSLABEL    = 106
  55. } OracleClientType;
  56.  
  57. @class OracleChannel;
  58.  
  59. // This is the abstract class from which all column types descend.  It
  60. // implements the various class methods, but subclasses must implement all of
  61. // the instance methods.
  62.  
  63. @interface OracleColumn:NSObject
  64.  
  65. + (OracleServerType)oracleServerTypeForName:(NSString *)typeName;
  66.     // Given an external type string from an attribute, this returns the type
  67.     // code for that data type as understood by OCI.
  68.  
  69. + formatAttribute:(EOAttribute *)attribute;
  70. + formatValue:value forAttribute:(EOAttribute *)attribute;
  71. + (BOOL)isValidQualifierType:(NSString *)typeName;
  72.     // Methods called by the EO framework (through the adaptor) to generate
  73.     // correct SQL.
  74.  
  75. + primitiveValueForCustomValue:value attribute:(EOAttribute *)attribute;
  76.     // Takes a custom value and extracts the primitive data type (NSString or
  77.     // NSData depending on the external type of the attribute).  Does nothing
  78.     // if the value is not a custom value.
  79.  
  80. + (EOAttribute *)attributeWithName:(NSString *)name
  81.     columnName:(NSString *)columnName externalType:(NSString *)dbType
  82.     externalLength:(int)dbLength precision:(int)precision scale:(int)scale;
  83.     // Builds an EOAttribute based on the standard set of information
  84.     // available in Oracle v7 about database columns.  This is called from
  85.     // attributeAtPosition:cursor: and by the describe routines.
  86.  
  87. + (EOAttribute *)attributeAtPosition:(int)position cursor:(Cda_Def *)cda;
  88.     // This uses odescr() to build an attribute for the item at position in
  89.     // the select list.  It can only by called after oparse() and before
  90.     // oexec().  Position indices start at 0.
  91.  
  92. - initWithAttribute:(EOAttribute *)attribute;
  93.     // This is the designated initializer for all OracleColumns.
  94.  
  95. - (int)columnLength;
  96.     // The length of a single element of the column type.
  97.  
  98. - (BOOL)defineWithCursor:(Cda_Def *)cda selectPosition:(unsigned)index 
  99.     rowCapacity:(unsigned)capacity;
  100.     // Called by the channel to allow the column to define the output buffers.
  101.  
  102. - (BOOL)canUseArrayFetching;
  103.     // If all of the OracleColumns in a select list return YES, then the
  104.     // channel will use array fetching to get more than one row at a time from
  105.     // the server.
  106.  
  107. - fetchFromIndex:(unsigned)index zone:(NSZone *)zone;
  108.     // This is the method which gets called to actually fetch data for a column
  109.     // Returns a *retained* object (caller must release).
  110.  
  111. @end
  112.  
  113. // This is the column class from which all primitive column types descend.
  114. // It implements the basics of talking to the client library to get data out
  115. // of the database.
  116.  
  117. @interface OracleConcreteColumn:OracleColumn
  118. {
  119.     NSString *_attributeName;
  120.     sb2 *_indicator;
  121.     ub2 *_returnLength;
  122.     ub2 *_returnCode;
  123.     ub1 *_columnBuffer;
  124.     
  125.     OracleClientType _clientType;
  126.     int _columnLength;
  127. }
  128.  
  129. - initWithAttribute:(EOAttribute *)attribute;
  130.     // Each column subclass must set _clientType and _columnLength in their
  131.     // initWithAttribute: method.
  132.  
  133. - (int)columnLength;
  134.     // This is a simple accessor for the _columnLength ivar.
  135.  
  136. - (BOOL)defineWithCursor:(Cda_Def *)cda selectPosition:(unsigned)index 
  137.     rowCapacity:(unsigned)capacity;
  138.     // Does the odefin () to set up the buffers for fetching data and getting
  139.     // the various return codes.  The instance variables _clientType and
  140.     // _columnLength must be set up by the subclasses before getting here.
  141.  
  142. - (BOOL)canUseArrayFetching;
  143.     // By default this returns YES.  Subclasses should return NO if they cannot
  144.     // use Oracle's array fetching API (if they need to use oflng ()).
  145.  
  146. @end
  147.  
  148. // These are the various kinds of primitive Oracle column buffers...
  149.  
  150. @interface OracleStringColumn:OracleConcreteColumn
  151. - initWithAttribute:(EOAttribute *)attribute;
  152. - fetchFromIndex:(unsigned)index zone:(NSZone *)zone;
  153. @end
  154.  
  155. @interface OracleDataFromStringColumn:OracleStringColumn
  156. - fetchFromIndex:(unsigned)index zone:(NSZone *)zone;
  157. @end
  158.  
  159. @interface OracleNumberColumn:OracleConcreteColumn
  160. - initWithAttribute:(EOAttribute *)attribute;
  161. - fetchFromIndex:(unsigned)index zone:(NSZone *)zone;
  162. @end
  163.  
  164. @interface OracleDataColumn:OracleConcreteColumn
  165. - initWithAttribute:(EOAttribute *)attribute;
  166. - fetchFromIndex:(unsigned)index zone:(NSZone *)zone;
  167. @end
  168.  
  169. @interface OracleDateColumn:OracleConcreteColumn
  170. {
  171.     EOAttribute *_attribute;
  172. }
  173. - initWithAttribute:(EOAttribute *)attribute;
  174. - fetchFromIndex:(unsigned)index zone:(NSZone *)zone;
  175. @end
  176.  
  177. // While all the other kinds of columns are based on the value they are going
  178. // to create, the OracleLongColumn is based on the value it has to fetch.
  179. // Getting a LONG or LONG RAW column out of the database requires some special
  180. // work.  It can return an NSString or an NSData.
  181.  
  182. @interface OracleLongColumn:OracleConcreteColumn
  183. {
  184.     Cda_Def *_cda;
  185.     int _position;
  186.     BOOL _objectIsData;
  187. }
  188. - initWithAttribute:(EOAttribute *)attribute;
  189. - (BOOL)canUseArrayFetching;
  190. - (BOOL)defineWithCursor:(Cda_Def *)cda selectPosition:(unsigned)position 
  191.     rowCapacity:(unsigned)capacity;
  192. - fetchFromIndex:(unsigned)index zone:(NSZone *)zone;
  193. @end
  194.  
  195. // The OracleCustomColumn is the only non-primitive column type.  It holds
  196. // another column which actually gets the data out of Oracle's buffers, and
  197. // then creates a custom class from that primitive data.
  198.  
  199. @interface OracleCustomColumn:OracleColumn
  200. {
  201.     OracleColumn *_realColumn;
  202.     NSString *_attributeName;
  203.     NSString *_valueType;
  204.     Class _valueClass;
  205.     BOOL _primitiveValueIsData;
  206.     BOOL _archivedObject;
  207.     BOOL _oldArchive;
  208. }
  209. - initWithAttribute:(EOAttribute *)attribute;
  210. - (int)columnLength;
  211. - (BOOL)defineWithCursor:(Cda_Def *)cda selectPosition:(unsigned)index 
  212.     rowCapacity:(unsigned)capacity;
  213. - (BOOL)canUseArrayFetching;
  214. - fetchFromIndex:(unsigned)index zone:(NSZone *)zone;
  215. @end
  216.  
  217.